package com.kws.system.controller.merchant;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.system.domain.info.QueryExtendInfo;
import com.kws.system.domain.vo.CreateExtendRq;
import com.kws.system.domain.vo.QueryExtendRq;
import com.kws.system.domain.vo.UpdateExtendRq;
import com.kws.system.service.ExtendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>ExtendController</b>
 *
 * @description: ExtendController <br>
 * @date: 2024/12/3 17:31 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "推广管理")
@RestController
public class ExtendController {
    private static final Logger logger = LoggerFactory.getLogger(ExtendController.class);

    @Autowired
    private ExtendService extendService;

    @ApiOperation("分页查询推广管理列表")
    @PostMapping("/query/extendPage")
    public R<Page<QueryExtendInfo>> queryExtendPage(@RequestBody QueryExtendRq rq){
        Page<QueryExtendInfo> pageInfo = extendService.queryExtendPage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("新增推广信息")
    @PostMapping("/create/extend")
    public R createExtend(CreateExtendRq rq){
        boolean status = extendService.createExtend(rq);
        return R.ok(status);
    }

    @ApiOperation("根据推广ID查询详情")
    @GetMapping("/query/extend/byId")
    public R<QueryExtendInfo> queryExtendById(@RequestParam Long id){
        QueryExtendInfo info = extendService.queryExtendById(id);
        return R.ok(info);
    }

    @ApiOperation("修改推广信息")
    @PostMapping("/update/extend/byId")
    public R updateExtendById(UpdateExtendRq rq){
        boolean status = extendService.updateExtendById(rq);
        return R.ok(status);
    }

    @ApiOperation("根据ID删除推广信息")
    @GetMapping("/delete/extend/byId")
    public R deleteExtendById(@RequestParam Long id){
        boolean status = extendService.deleteExtendById(id);
        return R.ok(status);
    }

}
